﻿using ThingyCloud.Creatures;

namespace ThingyCloud.Network.Messages
{
	class AvatarMoveMessage : Message
	{
		/// <summary>
		/// The avatar that moved
		/// </summary>
		private Avatar avatar;

		/// <summary>
		/// Generate a new message that an avatar moved
		/// </summary>
		/// <param name="avatar"></param>
		public AvatarMoveMessage(Avatar avatar)
		{
			this.avatar = avatar;
		}
		
		/// <summary>
		/// Format the message string
		/// </summary>
		/// <returns></returns>
		public override string ToMessageString()
		{
			return string.Format(
					"action:move;id:{0};crid:{1};var:{2};x:{3};y:{4};r:{5};w:{6};h:{7};",
					avatar.ID,
					avatar.Properties.ID,
					avatar.Variant.ID,
					Globals.ToAbsX(avatar.X),
					Globals.ToAbsY(avatar.Y),
					avatar.Direction,
					avatar.Width,
					avatar.Height
					);
		}
	}
}
